// 获取cookie的工具
function getCookie (name) {
  var cookie = document.cookie;
  var cookiearr = cookie.split("; ");
  for (var i = 0; i < cookiearr.length; i++) {
    var newarr = cookiearr[i].split("=");
    if (name == newarr[0]) {
      return decodeURI(newarr[1])
    }
  }
}
// 获取地址栏参数的方法
function GetQueryString (name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) {
    return decodeURI(r[2]);
  }
  return null;
}
// 获取购物车数量的方法
function getCartNum () {
  var cartnum = 0;
  $.ajax({
    url: "http://127.0.0.1:3000/cart/cartnum",
    type: "post",
    async: false, //同步
    success: function (res) {
      cartnum = res.cartnum;
    }
  })
  return cartnum
}
